﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ReconUI
{
    public partial class ReconSignIn : System.Web.UI.Page
    {
       // ContentPlaceHolder mpContentPlaceHolder;
        Label lblDateTime;
        protected void Page_Load(object sender, EventArgs e)
        {
          //  mpContentPlaceHolder = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
            lblDateTime = ((Label)Master.FindControl("lblDateTime"));
            lblDateTime.Visible = false;
        }

        protected void Page_PreRender(object sender, EventArgs e)
        {
            //set focus on the Customer ID text box
            ((TextBox)SignInControl.FindControl("txtCustID")).Focus();
        }

        protected void SignInControl_Authenticate(object sender, AuthenticateEventArgs e)
        {
            DBFactory db = new DBFactory();
            e.Authenticated = db.ValidateUser(SignInControl.UserName, SignInControl.Password, ((TextBox)SignInControl.FindControl("txtCustID")).Text);
            if (e.Authenticated)
            {
                UserVO loggedUser = (UserVO)HttpContext.Current.Session["CurrentUserVO"];
                /*if (loggedUser.isFourcePwdChange.Equals("Y"))
                {
                    Response.Redirect("~/ChangePassword.aspx");
                }*/
            }
            else
            {
                ((Label)SignInControl.FindControl("lblValidationFailure")).Visible = true;
            }
        }

        protected void SignInControl_LoggedIn(object sender, EventArgs e)
        {
            /*DBFactory db = new DBFactory();
            string userDetails = db.GetUserSpecificDetails(SignInControl.UserName);
            Session.Add(SessionStore.LoggedInUserName, userDetails.Split('~')[0]);
            Session.Add(SessionStore.CustomerID, userDetails.Split('~')[1]);*/
           // ClientScript.RegisterOnSubmitStatement(this.GetType(), "key", "return confirm('Do you want to submit the page?')");

            UserVO loggedUser = (UserVO)HttpContext.Current.Session["CurrentUserVO"];
            if (loggedUser.isFourcePwdChange.Equals("Y"))
            {
                Response.Redirect("~/ChangePassword.aspx");
            }
            else
                Response.Redirect("~/ReconHome.aspx");
        }
    }
}